//
//  XJ_ConfirmationMarginViewController.m
//  XunJieProject
//
//  Created by 薛子 on 2018/6/12.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "XJ_ConfirmationMarginViewController.h"
#import "XJ_ReturnListViewController.h"
@interface XJ_ConfirmationMarginViewController ()
@property (weak, nonatomic) IBOutlet UIButton *sureButton;
@property (weak, nonatomic) IBOutlet UILabel *allMarginLabel;//支付金额
@property (weak, nonatomic) IBOutlet UILabel *serviceChargeLabel;

@property (weak, nonatomic) IBOutlet UILabel *cashDepositLabel;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *viewTop;


@end

@implementation XJ_ConfirmationMarginViewController
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    // 禁用返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    // 开启返回手势
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.nav_titleLabel.text = @"确认保证金";
    
    _viewTop.constant = SafeAreaTopHeight;
    
    _sureButton.layer.cornerRadius = 5;
    
    _serviceChargeLabel.text = [NSString stringWithFormat:@"￥%@",_model.serviceCharge];
    _cashDepositLabel.text = [NSString stringWithFormat:@"￥%@",_model.cashDeposit];
    
    _allMarginLabel.text = [NSString stringWithFormat:@"支付金额：￥%@",_model.dealTotal];
    // Do any additional setup after loading the view from its nib.
}

- (IBAction)confirmationMarginAction:(id)sender {
    
    [self planConfirmationAction];
    
}

- (void)planConfirmationAction{
    
    NSUserDefaults * db = [NSUserDefaults standardUserDefaults];
    NSString * token = [db objectForKey:@"token"];
    
    NSMutableDictionary * dic = [NSMutableDictionary dictionary];
    [dic setValue:IDENTIFIER forKey:@"equipmentNo"];
    [dic setValue:APPVERSION forKey:@"appVersion"];
    [dic setValue:STSTERMVERSION forKey:@"systemVersion"];
    [dic setValue:USERID forKey:@"userId"];
    
    if (token!=nil &&![token isEqualToString:@""]) {
        
        [dic setValue:token forKey:@"token"];
        
    }

    
    [dic setValue:_model.planId forKey:@"planId"];
    
    
    [XJ_Utils signPost:@"plan/confirm?" parameters:dic success:^(NSInteger recode, id jsonObject) {
        
        XJ_ReturnListViewController * VC = [[XJ_ReturnListViewController
                                             alloc]init];
        VC.planID = _model.planId;
        [self.navigationController pushViewController:VC animated:YES];
        
    } failure:^(NSInteger recode, NSError *error) {
        
    }];
    
}
- (void)backButtonClick{
    
    [self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
